<template>
    <h2>添加科室信息</h2>
    <table border="1">
        <tr>
            <td>科室名称</td>
            <td>
                <input type="text" v-model="info.dept_Name">
            </td>
        </tr>
        <tr>
            <td>科室状态</td>
            <td>
                <input type="radio" value="繁忙" v-model="info.dept_State" checked name="A">繁忙
                <input type="radio" value="空闲" v-model="info.dept_State" name="A">空闲
                <input type="radio" value="停用" v-model="info.dept_State" name="A">停用
            </td>
        </tr>
        <tr>
            <td>门诊</td>
            <td>
                <input type="text" v-model="info.dept_Clinic">
            </td>
        </tr>
        <tr>
            <td>病区</td>
            <td>
                <input type="text" v-model="info.dept_Area">
            </td>
        </tr>
        <tr>
            <td>科室信息</td>
            <td>
                <input type="text" v-model="info.dept_Info">
            </td>
        </tr>
        <tr>
            <td>科室电话</td>
            <td>
                <input type="text" v-model="info.dept_Phone">
            </td>
        </tr>
        <tr>
            <td>科室类别</td>
            <td>
                <select v-model="info.deptType_Id">
                    <option value="">--请选择--</option>
                    <option v-for="item in bindt" :value="item.deptType_Id">{{ item.deptType_Name }}</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <input type="button" class="btn btn-info" value="保存" @click="add">
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'
import { onMounted } from 'vue'
onMounted(()=>{
    bind();
})
const bindt=ref([{
    "deptType_Id": 0,
    "deptType_Name": "string"
}])
const bind=()=>{
    axios.get('http://localhost:5021/api/Dept/Bind_t')
    .then(res=>{
        bindt.value=res.data
    })
    .catch(error=>{
        console.log(error);
    })
}
const info=ref({
    "dept_Id": 0,
    "dept_Name": "",
    "deptType_Id": 0,
    "dept_State": "",
    "dept_Clinic": "",
    "dept_Area": "",
    "dept_Info": "",
    "dept_Phone": ""
})
const add=()=>{
    axios.post('http://localhost:5021/api/Dept/AddDept',info.value)
    .then(res=>{
        if(res.data>0){
            alert('保存成功');
            return;
        }
        else{
            alert('保存失败');
            return;
        }
    })
}
</script>